<template>
	<view class="body">
		<view class="item" @click="goAuthentication('RealName')">
			<view class="disC">
				<image src="../../static/image/real_name.png" mode="widthFix" class="icon"></image>
				<view class="text">
					实名认证
				</view>
			</view>
			<view class="disC">
				<view class="status">{{userInfo.idCard ? '已认证' : '去认证' }}</view>
				<image src="../../static/icon/icon_01.png" mode="widthFix" class="right"></image>
			</view>

		</view>
		<view class="item" @click="goAuthentication('Student')">
			<view class="disC">
				<image src="../../static/image/student.png" mode="widthFix" class="icon"></image>
				<view class="text">
					学生认证
				</view>
			</view>
			<view class="disC">
				<view class="status">
					{{userInfo.isStudent ==  0 ? '认证不通过' : userInfo.isStudent ==  1 ? '已认证' : userInfo.isStudent ==  2 ? '待审核' : '未认证' }}
				</view>
				<image src="../../static/icon/icon_01.png" mode="widthFix" class="right"></image>
			</view>
		</view>
		<view class="item" @click="goAuthentication('BindPhone')">
			<view class="disC">
				<image src="../../static/image/phone.png" mode="widthFix" class="icon"></image>
				<view class="text">
					绑定手机号
				</view>
			</view>
			<view class="disC">
				<view class="status">{{userInfo.phone ? `${userInfo.phone}` : '未绑定' }}</view>
				<image src="../../static/icon/icon_01.png" mode="widthFix" class="right"></image>
			</view>

		</view>
		<view class="item">
			<view class="disC">
				<image src="../../static/image/privacy.png" mode="widthFix" class="icon"></image>
				<view class="text">
					隐私政策
				</view>
			</view>
			<view class="disC">
				<view class="status"></view>
				<image src="../../static/icon/icon_01.png" mode="widthFix" class="right"></image>
			</view>

		</view>
		<view class="refresh" @click='GetUser'>
			刷新信息
		</view>
	</view>
</template>

<script>
	import {
		getMemberInfo
	} from '@/api.js'
	export default {
		data() {
			return {
				userInfo: {},
			}
		},
		onLoad() {
			this.GetUser()

		},
		methods: {
			goAuthentication(name) {
				if (name == 'BindPhone' && this.userInfo.phone) {
					return
				}
				uni.navigateTo({
					url: '/pages/authentication/authentication?name=' + name
				})
			},
			async GetUser() {
				uni.showLoading()
				let res = await getMemberInfo({})
				this.userInfo = res.result
				uni.hideLoading()
				console.log('userInfo', this.userInfo);
				uni.setStorage({
					key: 'userInfo',
					data: JSON.stringify(res.result),
					success: function() {}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.disC {
		display: flex;
		align-items: center;
	}

	.body {
		background: #f8f8f8;
		height: 100vh;
		width: 100vw;
		padding: 30rpx 0;
		box-sizing: border-box;

		.item {
			height: 80rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #fff;
			margin: 0rpx 20rpx 30rpx 20rpx;
			width: 710rpx;

			.icon {
				width: 40rpx;
				margin: 0 20rpx;
			}

			.text {
				font-weight: 400;
				color: #000;
				font-size: 28rpx;
			}

			.status {
				font-weight: 400;
				font-size: 28rpx;
			}

			.right {
				width: 30rpx;
				margin: 0 10rpx;
			}
		}

		.refresh {
			height: 80rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background: #fff;
			margin: 30rpx 20rpx;
			width: 710rpx;
			font-weight: 400;
			font-size: 28rpx;
		}
	}
</style>